package com.juyu.miliao.common.pojo;

import java.time.LocalDate;
import java.time.LocalDateTime;

public class DateTimePeriod {
	private LocalDateTime startTime;
	private LocalDateTime endTime;

	public DateTimePeriod(){
		
	}
	
	public DateTimePeriod(LocalDateTime startTime, LocalDateTime endTime){
		this.startTime = startTime;
		this.endTime = endTime;
	}
	
	public LocalDateTime getStartTime() {
		return startTime;
	}

	public void setStartTime(LocalDateTime startTime) {
		this.startTime = startTime;
	}

	public void setStartTime(LocalDate startDate) {
		this.startTime = startDate.atTime(0, 0, 0);
	}
	
	public LocalDateTime getEndTime() {
		return endTime;
	}
	
	public void setEndTime(LocalDateTime endTime) {
		this.endTime = endTime;
	}
	
	public void setEndTime(LocalDate endDate) {
		this.endTime = endDate.atTime(23, 59, 59);
	}

	public DatePeriod toDatePeriod(){
		DatePeriod datePeriod = new DatePeriod();
		if(startTime != null)
			datePeriod.setStartDate(startTime.toLocalDate());
		if(endTime != null)
			datePeriod.setEndDate(endTime.toLocalDate());
		return datePeriod;
	}
	
}
